package com.fan.leetcode;

/**
 * 470. 用 Rand7() 实现 Rand10()
 *
 * @author ZhangFan
 * @since 2021/9/5 下午 4:32
 */
public class Question470 {
    public int rand10() {
        int row, col, num;
        do {
            row = rand7();
            col = rand7();
            num = col + (row - 1) * 7;
        } while (num < 40);
        return (num - 1) % 10 + 1;
    }

    /**
     * The rand7() API is already defined in the parent class SolBase.
     * public int rand7();
     * @return a random integer in the range 1 to 7
     */
    private int rand7() {
        return 0;
    }

}
